from config import *
import socket
import time,select

runOn = 'a'
peerPublicPort = 12769

a = socket.socket(type=socket.SOCK_DGRAM)
add = ('0.0.0.0',54321)
a.bind(add)
a.setsockopt(socket.IPPROTO_IP,socket.IP_TTL,8)

if runOn == 'a':    
    add = (bPublicIp,peerPublicPort)
else :
    add = (aPublicIp,peerPublicPort)
    

needSend = True
while True:
    if needSend:
        a.sendto(b'dfedf',add)
    r,w,e = select.select([a],[],[],1)
    if  r:
        try:
            b = a.recvfrom(65536)
        except:
            time.sleep(1)
            continue
        print(b)
        if len(b[0])>10:
            needSend = False